<template>
  <view>
    <view class="colorB" style="padding:30rpx;" v-for="(item ,index) in connectorList" :index="index" :key="index">
      <view class="mainColor border-10" style="border: 1px solid #fff;">
        <view class="flex justify-between align-center padding-10">
          枪口编号：{{item.pileConnectorCode}}
        </view>
        <view class=" padding-10">状态：{{connectorStatus(item.status) }}</view>
        <view class=" padding-10">电桩类型：{{connectorType(item.type) }}</view>
        <!-- <view class="flex justify-between align-center padding-10">
          <view class="">站点类型：{{stationtype(item.stationType)}}</view>
          <view class="">站点状态：{{stationStatus(item.stationStatus )}}</view>
        </view> -->
        <view class="padding-10">功率（kw）：{{item.instantPower || '一'}}</view>
        <view class="text padding-10">电流（A）：{{item.current || '一'}}</view>
        <view class="text padding-10">电压（V）：{{item.voltage || '一'}}</view>
        <view class="text padding-10">温度（℃）：{{item.temperature || '一'}}</view>
        <view class="text padding-10">SOC（％）：{{item.soc || '一'}}</view>
        <!-- <view class="text padding-10">微信商户订单号：{{item.outTradeNo === null ? '一':item.outTradeNo}}</view> -->
      </view>
    </view>

    <!-- 分页 -->
    <uni-pagination show-icon :page-size="queryParams.pageSize" :current="queryParams.pageNum" :total="total"
      @change="change" />
    <view class="btn-view;mainColor border-10">
      <view class="">
        <text
          class="example-info">当前页：{{ queryParams.pageNum }}，数据总量：{{ total }}条，每页数据：{{ queryParams.pageSize }}</text>
      </view>
      <view class="btn-flex ">
        <button class="button word-btn" hover-class="word-btn--hover" :hover-start-time="20" :hover-stay-time="70"
          @click="add"><text class="word-btn-white">增加10条数据</text></button>
        <button class="button" type="default" @click="reset" style="margin-left: 40rpx;">重置数据</button>
      </view>
    </view>
  </view>
</template>

<script>
  import {
    checkPermi,
    checkRole
  } from "@/utils/permission";
  import {
    queryConnectorListByParams
  } from "@/api/pile/connector";
  import {
    connectorStatus,
    connectorType,
    payStatus
  } from '@/common/dict.js'
  export default {
    props: ['stationId'],
    data() {
      return {
        connectorStatusList: [],
        connectorTypeList: [],
        payStatusList: [],
        // 总条数
        total: 0,
        // 订单表格数据
        connectorList: [],
        // 订单详情表格数据
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          stationIdList: [],
        }
      };
    },
    methods: {
      checkPermi,
      checkRole,
      add() {
        this.queryParams.pageSize += 10
        this.getList();
      },
      reset() {
        this.queryParams.pageSize = 10
        this.queryParams.pageNum = 1
        this.getList();
      },
      change(e) {
        console.log(e.current);
        this.queryParams.pageNum = e.current
        this.getList()
      },
      connectorType(sim) {
        connectorType.then(result => {
          this.connectorTypeList = result
        })
        let str = this.connectorTypeList.find(item => item.dictValue == sim)
        if (str == undefined) {
          return '一'
        } else {
          return str.dictLabel
        }
      },
      payStatus(sim) {
        payStatus.then(result => {
          this.payStatusList = result
        })
        let str = this.payStatusList.find(item => item.dictValue == sim)
        if (str == undefined) {
          return '一'
        } else {
          return str.dictLabel
        }
      },
      connectorStatus(sim) {
        connectorStatus.then(result => {
          this.connectorStatusList = result
        })
        let str = this.connectorStatusList.find(item => item.dictValue == sim)
        if (str == undefined) {
          return '一'
        } else {
          return str.dictLabel
        }
      },
      getList() {
        console.log(this.stationId, 'this.stationId');
        this.queryParams.stationIdList.push(this.stationId);
        queryConnectorListByParams(this.queryParams).then(response => {
          this.connectorList = response.rows;
          console.log('this.connectorList', this.connectorList)
          this.total = response.total;
        });
      },
    },
    created() {
      this.getList()
    }
  }
</script>

<style lang="scss">

</style>